<?php

/**
 * Created by JetBrains PhpStorm.
 * User: Đặng Khánh Trung
 * Date: 11/1/12
 * Time: 8:58 PM
 * To change this template use File | Settings | File Templates.
 */
// No direct access to this file
defined('_JEXEC') or die('Restricted access');

// import Joomla modelitem library
jimport('joomla.application.component.modelitem');
jimport('joomla.html.pagination');

/**
 * Vast Model
 */
class VastModelVast extends JModelItem {
    public function getStatistics()
    {
        $result = array();
        $db = JFactory::getDbo();
        $query = $db->getQuery(true);
        
        $query->select('a.*, COUNT(*) AS sokhoi');
        $query->from('#__khoi AS a');
       
        $db->setQuery($query);
        $tmp = $db->loadObject();
                
        $result['numOfKhois'] = $tmp->sokhoi;
        
        $query = $db->getQuery(true);
        
        $query->select('a.*, COUNT(*) AS sodonvi');
        $query->from('#__donvi AS a');
       
        $db->setQuery($query);
        $tmp = $db->loadObject();
        
        $result['numOfDonvis'] = $tmp->sodonvi;
        
        $query = $db->getQuery(true);
        
        $query->select('a.*, COUNT(*) AS sophong');
        $query->from('#__phong AS a');
       
        $db->setQuery($query);
        $tmp = $db->loadObject();
        
        $result['numOfPhongs'] = $tmp->sophong;
        
        $query = $db->getQuery(true);
        
        $query->select('a.*, COUNT(*) AS sohosocanbo');
        $query->from('#__hosocanbo AS a');
       
        $db->setQuery($query);
        $tmp = $db->loadObject();
        
        $result['numOfHosocanbos'] = $tmp->sohosocanbo;

        $query = $db->getQuery(true);
        
        $query->select('a.*, COUNT(*) AS socongtrinh');
        $query->from('#__congtrinh AS a');
       
        $db->setQuery($query);
        $tmp = $db->loadObject();
        
        $result['numOfCongtrinhs'] = $tmp->socongtrinh;

        return $result;
    }
}